package javax.core.common.utils;

public class StringUtils {

	/**
	 * 字符串，首字母小写
	 **/
	public static String firstLowerCase(String text) {
		if (text == null || text.trim().isEmpty()) {
			return text;
		}

		char[] chars = text.toCharArray();
		chars[0] += 32;
		return String.valueOf(chars);
	}

	/**
	 * 字符串，首字母大写
	 **/
	public static String firstUpperCase(String text) {
		if (text == null || text.trim().isEmpty()) {
			return text;
		}

		char[] chars = text.toCharArray();
		chars[0] -= 32;
		return String.valueOf(chars);
	}

	/**
	 * <p>
	 * 判断字符串是否为空
	 * </p>
	 *
	 * @param cs 需要判断字符串
	 * @return 判断结果
	 */
	public static boolean isEmpty(final CharSequence cs) {
		int strLen;
		if (cs == null || (strLen = cs.length()) == 0) {
			return true;
		}
		for (int i = 0; i < strLen; i++) {
			if (!Character.isWhitespace(cs.charAt(i))) {
				return false;
			}
		}
		return true;
	}

	/**
	 * <p>
	 * 判断字符串是否不为空
	 * </p>
	 *
	 * @param cs 需要判断字符串
	 * @return 判断结果
	 */
	public static boolean isNotEmpty(final CharSequence cs) {
		return !isEmpty(cs);
	}
}
